/*
 * @Descripttion: 实现new关键字
 * @version: 1.0.0
 * @Author: 某人
 * @Date: 2021-06-04 11:47:46
 */

function objectFactory () {
  let obj = new Object()
  Constructor = [].shift.call(arguments)
  obj.__proto__ = Constructor.prototype
  let ret = Constructor.apply(obj, arguments)
  return typeof ret === 'object' ? ret || obj : obj
}

function person(name, age) {
  this.name = name
  this.age = age
}
let p = objectFactory(person, '布兰',12)
console.log(p)